<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>天禾人才</title>
	<meta name="format-detection" content="telephone=no">
	<meta name="viewport" content="minimal-ui=yes,width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<meta name="msapplication-tap-highlight" content="no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">

	<link rel="stylesheet" type="text/css" href="css/public.css">
	<link rel="stylesheet" type="text/css" href="css/password.css">
</head>
<body>
	<div class="header">
		<div class="top">
			<div class="sn-nav-back">
				<a href="javascript:;" onclick="javascript:history.back(-1);"><img src="img/back.png"></a>
			</div>
			<div class="sn-nav-title of">忘记密码</div>
		</div>
	</div>
	<div class="container">
		<div class="password">
			<div class="input">
				<label>手机号</label>
				<input type="text" name="phone" id="phone"/>
			</div>
			<div class="input">
				<label>验证码</label>
				<input type="text" nema="yzm" id="yzm"/>
				<a href="javascript:;" class="yzm" id="yzm_btn">获取验证码</a>
			</div>

			<div class="input">
				<label>新密码</label>
				<input type="password" name="password" id="password"/>
			</div>
			<div class="input">
				<label>确认密码</label>
				<input type="password" name="repassword" id="repassword"/>
			</div>
			<div class="btn">
				<a class="per-btn" href="javascript:;" id="submit">提交</a>
			</div>
		</div>
	</div>	
</body>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/base.js"></script>
<script type="text/javascript">
$("#submit").click(function(){
	var code = $("#yzm").val();
	var phone = $("#phone").val();
	var pwd = $("#password").val();
	var rePwd = $("#repassword").val();
	if(code == null || code == "") {
		alert("请输入验证码");
		return false;
	}
	if(pwd == null || pwd == "") {
		alert("请输入新密码");
		return false;
	}
	if(pwd != rePwd) {
		alert("两次输入的密码不一致");
		return false;
	}
	//修改密码
	$.ajax({
		type: "POST",
		url: "/user/pwd/find",
		data:{
			"code" : code,
			"phone" : phone,
			"pwd" :　pwd
		},
		dataType:"json",
		async:false,
		success: function(data){
			if(data.code == 0){
				alert("修改密码成功");
				localStorage.removeItem('user_info');
				window.location.href="login.html";
			}else{
				alert(data.msg);
				return false;
			}
		}
	});
});

$("#yzm_btn").click(function(){
	if($(this).hasClass('unclick')){
		return false;
	}
	var reg=/^(((1[0-9][0-9]{1})|159|153)+\d{8})$/;
	var phone= $.trim($("#phone").val());
	if(!reg.test(phone)){
		alert("请输入正确的手机号");
		return false;
	}
	$.ajax({
		type: "POST",
		url: "/util/sms/send/findPwd",
		data: {
			"phone":phone
		},
		dataType:"json",
		async:false,
		success: function(data){
			if(data.code != 0) {
				alert(data.msg);
			}else {
				$("#yzm_btn").addClass('unclick');
				$("#yzm_btn").html('90秒后重新获取');
				timedCount();
			}
		},error:function(data){
			alert("获取验证码失败");
		}
	});
});

var c=0 ;
function timedCount(){
	$("#yzm_btn").addClass('unclick');
	c++;
	if(c==90){
		$("#yzm_btn").removeClass('active');
		$("#yzm_btn").text("获取验证码");
		$("#yzm_btn").removeClass('unclick');
		c=0;
		return false;
	}else{
		$("#yzm_btn").text((90-c)+"秒后重新获取");
	}
	setTimeout("timedCount()",1000);
};
</script>
</html>